﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MVCManage.Model.Base
{
    public abstract class BaseBLL<T>where T : class,new()
    {
        public BaseDAL<T> Dal { get; set; }
        public BaseBLL() {
            SetDal();
        }

        public abstract void SetDal();

        public bool Add(T t)
        {
            Dal.Add(t);
            return Dal.SaveChanges();

        }

        public bool Add(List<T> list)
        {
            Dal.Add(list);
            return Dal.SaveChanges();

        }

        public bool Delete(T t)
        {
            Dal.Delete(t);
            return Dal.SaveChanges();

        }

        public bool Delete(List<T> list)
        {
            Dal.Deletes(list);
            return Dal.SaveChanges();
        }
        public bool Update(T t)
        {
            Dal.Update(t);
            return Dal.SaveChanges();

        }

        public IQueryable<T> Query()
        {
            return Dal.Query();
        }

        public List<T> QueryList()
        {
            return Dal.Query().ToList();
        }



    }
}
